// 创建Socket.IO实例，建立连接
 var socket = io();
socket.connect(); 

// 添加一个连接监听器
socket.on('connect',function() {
  console.log('Client has connected to the server!');
});

// 添加一个连接监听器
socket.on('msgSend',function(data) {
  var div = document.createElement('div');
  div.innerText = data['msg'];
  document.getElementById('message').appendChild(div);
});

// 添加一个关闭连接的监听器
socket.on('disconnect',function() { 
  console.log('The client has disconnected!'); 
}); 
document.getElementById('send').onclick = function(){
  socket.emit('msgSend', {msg:document.getElementById('infos').value});
}